<?php
//模型
class DictModel extends MY_Model {
	function __construct(){
		parent::__construct();
		$this->table = 'dict';
	}
	
	function get_list($arr,$page=1,$size=10){
		$where = ' 1 ';
		
		if(isset($arr['name']) && !empty($arr['name'])){
			$where .= " AND name like '%{$arr['name']}%'";
		}
		
		
		$res = $this->_where_get_list($where,$page,$size);
		return $res;
	}
	
	function get_info($id){
		$sql  = "select * from ".$this->db->dbprefix.$this->table." where id='{$id}' limit 1";
		$query = $this->db->query($sql);
		$row = $query->row_array();
		return $row;
	}
	
	function get_fields($name){
		$info = $this->_field_get_info($name,'name');
		if(!$info){
			return false;
		}
		$this->load->model('System/DictFieldModel','DictFieldModel');
		$list = $this->DictFieldModel->getAll(array('dict_id'=>$info['id']));
		return $list;
	}
}

